package com.example.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author circle48
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum implements BaseEnum{
    WAIT_PAY(0,"待付款"),
    WAIT_ROG(1,"待发货"),
    WAIT_RECEIVE(2,"已发货"),
    COMPLETE(3,"已完成"),
    CLOSED(4, "已关闭"),
    INVALID(5, "无效订单");


    @EnumValue
    private final int value;
    private final String desc;

    @JsonValue
    @Override
    public int getValue() {
        return value;
    }
    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static OrderStatusEnum of(Integer value) {
        if (value == null) {
            return null;
        }
        for (OrderStatusEnum status : values()) {
            if (status.value == value) {
                return status;
            }
        }
        return null;
    }

    public static String desc(Integer value) {
        OrderStatusEnum status = of(value);
        return status == null ? "" : status.desc;
    }
}
